<%--
  Created by IntelliJ IDEA.
  User: 28101
  Date: 2021/9/22
  Time: 9:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link href="/css/bootstrap-theme.css" rel="stylesheet">
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/myform.css" rel="stylesheet">
    <script src="/js/jquery-3.3.1.min.js"></script>
    <title>register</title>
    <style>
        .spandiv{
            margin-top: 40px;
        }
    </style>
</head>
<body>

    <div class="container myDiv table-bordered">
        <form action="/UserServlet?method=register" method="post">
            <div class="form-group col-md-12 myDivCol">
                name: <input class="form-control" placeholder="昵称" type="text" name="name">
            </div>
            <div class="form-group col-md-6 myDivCol">
                username: <input class="form-control" placeholder="账号" type="text" name="username" id="username">
            </div>
            <div class="form-group col-md-6 myDivCol spandiv">
                <span id="uSpan" style="float: left;color: red;position: relative"></span>
            </div>
            <div class="form-group col-md-12 myDivCol">
                pass: <input class="form-control" placeholder="密码" type="password" name="password">
            </div>
            <div class="form-group col-md-12 myDivCol">
                address: <input class="form-control" placeholder="默认收货地址" type="text" name="address">
            </div>
            <div class="form-group col-md-6 myDivCol">
                tel: <input class="form-control" placeholder="默认收获人电话" type="text" name="tel">
            </div>
            <div class="form-group col-md-12 myDivCol">
                <input class="mySub" type="submit" value="确认">
                <input id="btnToSelect" class="mySub" type="button" value="返回">
            </div>
        </form>
    </div>

    <script src="/js/bootstrap.min.js"></script>

    <script>
        $("#btnToSelect").click(function() {
            if (confirm("确定要返回吗？")){
                window.location.href = "/UserServlet?method=getUserByPage";
            }
        });

        $("#username").blur(function () {
            var username = $(this).val();
            console.log("111");
            $.get(
                "/UserServlet",
                "method=selectUidByUsername&username=" + username,
                function (data) {
                    console.log(data);
                    $("#uSpan").html(data);
                },
                "text"
            )
        });

    </script>

</body>
</html>
